package cn.com.haopy.yue.ai.wx.web;


import cn.com.haopy.yue.ai.core.utils.ResponseUtil;
import cn.com.haopy.yue.ai.wx.annotation.LoginUser;
import cn.com.haopy.yue.ai.wx.service.WxHOSUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 对象存储服务
 */
@RestController
@RequestMapping("/haopyYueAi/user")
@Api(tags = "用户信息接口")
@Slf4j
public class WxUserController {

    @Autowired
    private WxHOSUserService wxHOSUserService;


    @GetMapping("/getUserInfo")
    public Object getUserInfo(@LoginUser Integer userId) {
        if (null == userId) {
            return ResponseUtil.unlogin();
        }
        return ResponseUtil.ok(wxHOSUserService.getUserInfo(userId));
    }


    @GetMapping("/setUserInfo")
    public Object setUserInfo(@LoginUser Integer userId, @RequestParam String nickName,
                              @RequestParam String avatarUrl) {
        if (null == userId) {
            return ResponseUtil.unlogin();
        }
        return wxHOSUserService.setUserInfo(userId, nickName, avatarUrl);
    }


}